package nowcoder.day_48.day10;

/**
 * CM62 井字棋
 */
public class Num2 {
    public class Board {
        public boolean checkWon(int[][] board) {
            // write code here
            int n = board.length;
            int sum = 0;
            //求每行的和
            for(int i = 0 ; i < n ; i++){
                sum = 0;
                for(int j = 0 ; j < n ; j++){
                    sum += board[i][j];
                }
                if(sum == n)return true;
            }
            sum = 0;
            //求每行的和
            for(int i = 0 ; i < n ; i++){
                sum = 0;
                for(int j = 0 ; j < n ; j++){
                    sum += board[j][i];
                }
                if(sum == n)return true;
            }
            sum = 0;
            //求主对角线的和
            for(int i = 0 ; i < n ; i++){
                sum += board[i][i];
            }
            if(sum == n)return true;
            sum = 0;
            //求副对角线的和
            for(int i = 0 ; i < n ; i++){
                sum += board[i][n - 1 - i];
            }
            if(sum == n)return true;
            return false;
        }
    }

}
